#pragma once

#include "sysx/pch.h"

namespace sysx
{
    struct System
    {
        struct Filter
        {
            std::string m_Name;
            std::vector<std::string> m_Patterns;
        };
        struct Filters
        {
            Filters()
            {

            };
            std::vector<Filter> m_Filters;

            std::string GenerateFilterString() const
            {
                std::ostringstream filterStream;

                for (const auto& filter : m_Filters)
                {
                    filterStream << filter.m_Name << '\0';

                    for (size_t i = 0; i < filter.m_Patterns.size(); ++i)
                    {
                        filterStream << filter.m_Patterns[i];
                        if (i < filter.m_Patterns.size() - 1)
                        {
                            filterStream << ';';
                        }
                    }
                    filterStream << '\0';
                }

                return filterStream.str();
            }

        };

        static bool RevealDir(const std::string& dir);
        
        static bool ExecuteCmd(const std::string& cmd, bool newCmdWindow = false);

        static void Init(int argc, char* argv[]);

        static std::string OpenDialog(const std::string& title, const Filters& filters = Filters(), std::string submitBtn = "Open", std::string cancelBtn = "Cancel");

        static std::string SaveDialog(const std::string& title, const Filters& filters = Filters(), const std::string& defaultFilename = "Untitle", std::string submitBtn = "Save", std::string cancelBtn = "Cancel");

        static std::string GetHome()
        {

#ifdef _WIN32
            const char* home = std::getenv("USERPROFILE");
            if (home) {
                fs::path homePath = home;
                return homePath.string();
            }
            return "./";
#endif
#ifdef __linux__
            return "~";
#endif

        };
    };
};
